<?php
session_start();

// includes
	include_once "quickcrud_connect.php";
	include_once "CFclass/CF_mysql_com.php";
	include_once "CFclass/CF_process_class.php";
	include_once "projects_fields.php";

class process extends CFprocess {

	function on_pre_delete(){

		$project_id = $this->newvalues['project_id'];
		$qry_clear_cols = "DELETE FROM crudcols 
		WHERE crudset_id IN (SELECT crudset_id FROM crudsets WHERE project_id = $project_id)";
		//print $qry_clear_cols;
		//exit;
		do_query($qry_clear_cols);
		do_query("DELETE FROM crudsets WHERE project_id = $project_id");
		do_query("DELETE FROM tablesources WHERE project_id = $project_id");
		do_query("DELETE FROM variables WHERE project_id = $project_id");
		
	}

	function on_post_add(){
		$project_id = $this->newvalues['project_id'];
		$project_name = $this->newvalues['project_name'];
		$qry_add_defaults = "UPDATE projects SET project_path = '$project_name', project_server = 'localhost' WHERE project_id = $project_id";
		do_query($qry_add_defaults);
		
	}



}
	
$process = new process($fieldspec, "projects_list.php");

$process->set_maintable('projects');

$process->do_actions();










?>